﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MSpecLauncher.Model
{
    public class Config
    {
        public bool AutodetectChanges { get; set; }
        public bool ShowCommandWindow { get; set; }
        public string MSpecLocation { get; set; }
        public IList<string> Assemblies { get; set; }
        public string OutputFolder { get; set; }

        public Config()
        {
            this.AutodetectChanges = false;
            this.ShowCommandWindow = false;
            this.Assemblies = new List<string>();
        }

        /// <summary>
        /// Checks if the required values are present
        /// </summary>
        public bool IsComplete()
        {
            return
                !string.IsNullOrEmpty(this.MSpecLocation) &&
                !string.IsNullOrEmpty(this.OutputFolder) &&
                this.Assemblies != null &&
                this.Assemblies.Count > 0;
        }

        public string GenerateCmd(string xmlFileName, string htmlFileName, out string args)
        {
            string assemblies = "";
            foreach (string assembly in this.Assemblies)
            {
                assemblies += assembly + " ";
            }
            assemblies = assemblies.Trim();

            args = string.Format("--timeinfo --xml {0} --html {1} {2}", xmlFileName, htmlFileName, assemblies);

            return this.MSpecLocation;
        }

        public string GenerateXMLFileName()
        {
            return Path.Combine(this.OutputFolder, "Specs.xml");
        }

        public string GenerateHTMLFileName()
        {
            return Path.Combine(this.OutputFolder, "Specs.html");
        }

    }
}
